package net.action;

import net.domain.User;
import net.service.UserService;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

/**
 * Created by zyh on 2017/2/27.
 */
@Controller
@Scope("prototype")
public class UserAciton {
    private String message;
    private String username;
    private String password;

    @Resource
    private UserService userService;

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    /*注册界面*/
    public String registerUi(){
       return "registerUi";
    }
    public String register(){
        boolean b= userService.findByUsernamePassword(username,password);
        System.out.println("name:"+username);

        if (!b){

            message = "注册失败，用户已存在";
            return "registerFail";
        }else {
            message = "注册成功";
            return "registerSuccess";

        }
    }

}
